<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    <div class="container-div">
    <div class="row">
    	<div class="col-sm-12 search-collapse">
				<form id="wdInfo-form">
					<div class="select-list">
						<ul>
							<li>
								年：<input type="text" name="wdYear"/>
							</li>
							<li>
								月：<input type="text" name="wdMonth"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="pm:wdInfo:add">
				<i class="fa fa-plus"></i> 添加
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="pm:wdInfo:edit">
	            <i class="fa fa-edit"></i> 修改
	        </a>
			<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="pm:wdInfo:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
			<a class="btn btn-success" onclick="createWorkDt()" >
			    <i class="fa fa-download"></i> 生成日历
			</a>
		</div>
			
		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var detailFlag = [[${@permission.hasPermi('pm:wdInfo:detail')}]];
        var datas = [[${@dict.getType('pm_date_type')}]];
        var prefix = ctx + "pm/wdInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                detailUrl: prefix + "/detail/{id}",
                modalName: "工作日历",
                uniqueId:"wdId",
                search:false,
                showSearch:false,
                showColumns:false,
                showToggle:false,
                showExport:false,
                showRefresh:false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'wdId', 
					title : '主键',
					visible: false
				},
				{
					field : 'wdYear', 
					title : '年' 
				},
				{
					field : 'wdMonth', 
					title : '月' 
				},
				{
					field : 'wdDay', 
					title : '日' 
				},
				{
					field : 'wdDate', 
					title : '日期',
					visible: false
				},
				{
					field : 'wdWeek', 
					title : '星期' 
				},
				{
					field : 'wdDtType', 
					title : '日期类型' ,
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
				},
				{
					field : 'wdNote', 
					title : '备注' 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.wdId + '\')"><i class="fa fa-search"></i>详细</a> ');
		            	return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function createWorkDt(){
        	var wdYear = $("input[name='wdYear']").val();
			var data ={"wdYear": wdYear};
			$.modal.loading("正在生成日历数据，请稍后...");
			$.post(prefix + "/createWorkDt", data, function(result) {
				$.modal.msgSuccess("生成日历数据成功");
				$.table.refresh();
				$.modal.closeLoading();
			});
        }
    </script>
</body>
</html>